package com.woniuxy.controller;

import com.woniuxy.entity.ClassRoom;
import com.woniuxy.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @BelongsProject: java-85-course-code
 * @BelongsPackage: com.woniuxy.controller
 * @Author: LiTongMiao
 * @Date: 2022/1/24 17:35
 * @Description: TODO
 */
@Controller
@RequestMapping("/form")
public class FormSendParamsController {
    @RequestMapping("/StringValue")
    public ModelAndView receiveParameters(String name){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","接受到的前端参数是："+name);
        modelAndView.setViewName("myTest");
        return modelAndView;
    }
    @RequestMapping("/ArrayValue")
    public ModelAndView receiveParameters(String[] ids){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","接收到的前端参数是："+ Arrays.toString(ids));
        modelAndView.setViewName("myTest");
        return modelAndView;
    }
    @RequestMapping("/ListValue")
    public ModelAndView receiveParameters(@RequestParam List<Integer> ids){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","接收到的前端参数是："+ ids);
        modelAndView.setViewName("myTest");
        return modelAndView;
    }
    @RequestMapping("/MapValue")
    public ModelAndView receiveParameters(@RequestParam Map<String,Object> user){
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("msg","接受到前端参数是："+user.toString());
        modelAndView.setViewName("myTest");
        return modelAndView;
    }
    @RequestMapping("/UserValue")
    public ModelAndView receiveParameters(User user) {
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("msg","接受到前端参数是："+user.toString());
        modelAndView.setViewName("myTest");
        return modelAndView;
    }
    @RequestMapping("/ClazzUserValue")
    public ModelAndView receiveParameters(ClassRoom classRoom) {
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("msg","接受到前端参数是："+classRoom.toString());
        modelAndView.setViewName("myTest");
        return modelAndView;
    }


}
